package com.gitee.hifong45;

import com.gitee.hifong45.sub.SubPrj;
import com.gitee.hifong45.sub.ProjectInfo;

import cn.hutool.core.net.NetUtil;

public class Prj {
    /**
	 * 编译时间实现：
	 * <p>1. pom.xml中加 &lt;properties&gt; &lt;project.build.time&gt;@maven.build.timestamp@&lt;/project.build.time&gt; &lt;/properties&gt;
	 * <p>2. application.properties中加: project.build.time=@project.build.time@
	 * 
	*/
	public static void printProjectInfo() {
		// String active = Str.orElse(SpringUtil.getActiveProfile(), "No setting");
		// String port = Str.orElse(SpringUtil.getProperty("server.port"), "8080");
		// String version = Str.orElse(SpringUtil.getProperty("app.version"), "No setting");
		// String prjBuildTime = SpringUtil.getProperty("project.build.time");
        // if(prjBuildTime == null) {
        //     Console.log("没有配置编译时间。此次进行处理");
        //     SubPrj.setBuildTime();
        // } else {
        //     prjBuildTime = LocalDateTimeUtil.formatNormal(LocalDateTimeUtil.parse(prjBuildTime.replace("Z", "")).plusHours(8));
        // }
        ProjectInfo prjInfo = SubPrj.getProjectInfo();
        String prjInfoStr = new StringBuffer()
                .append("\r\n\t=================project=================\n")
                .append(String.format("\n\t  running [env: %s], [IP: PORT]: %s:%s\n", prjInfo.active, NetUtil.getLocalhostStr(), prjInfo.port))
                .append(String.format("\tversion: %s, build time : %s\n", prjInfo.version, prjInfo.buildTime))
                .append("\n\t=================project=================\n")
                .toString();
       System.out.println(prjInfoStr);
	}
    public static ProjectInfo getProjectInfo() {
        return SubPrj.getProjectInfo();
    }
}
